/*
 * Created by JFormDesigner on Mon Jun 27 14:10:42 CST 2022
 */

package com.keshe.jsp;

import com.keshe.service.RoomInContorller;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.GroupLayout;

/**
 * @author 1
 */
public class CheckRoom extends JFrame {
    public CheckRoom() {
        initComponents();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");
        label1 = new JLabel();
        label2 = new JLabel();
        textField1 = new JTextField();
        button1 = new JButton();
        button2 = new JButton();
        panel1 = new JPanel();
        action1 = new back();
        action2 = new check();

        //======== this ========
        setIconImage(new ImageIcon(getClass().getResource("/images/\u9152\u5e97 (1).png")).getImage());
        setTitle("\u9000\u623f\u529e\u7406");
        Container contentPane = getContentPane();

        //---- label1 ----
        label1.setText(bundle.getString("label1.text_16"));
        label1.setHorizontalAlignment(SwingConstants.CENTER);
        label1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 30));
        label1.setIcon(new ImageIcon(getClass().getResource("/images/\u9000\u623f\u6362\u7968\u8bb0\u5f55.png")));

        //---- label2 ----
        label2.setText(bundle.getString("label2.text_9"));
        label2.setIcon(new ImageIcon(getClass().getResource("/images/257\u7528\u6237\u8d44\u6599-\u7ebf\u6027.png")));

        //---- button1 ----
        button1.setAction(action2);

        //---- button2 ----
        button2.setAction(action1);

        //======== panel1 ========
        {

            GroupLayout panel1Layout = new GroupLayout(panel1);
            panel1.setLayout(panel1Layout);
            panel1Layout.setHorizontalGroup(
                panel1Layout.createParallelGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
            );
            panel1Layout.setVerticalGroup(
                panel1Layout.createParallelGroup()
                    .addGap(0, 30, Short.MAX_VALUE)
            );
        }

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                    .addGap(0, 2, Short.MAX_VALUE)
                    .addComponent(label1, GroupLayout.PREFERRED_SIZE, 501, GroupLayout.PREFERRED_SIZE))
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(113, 113, 113)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                        .addComponent(button1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(label2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addComponent(textField1, GroupLayout.PREFERRED_SIZE, 166, GroupLayout.PREFERRED_SIZE))
                        .addGroup(contentPaneLayout.createSequentialGroup()
                            .addGap(1, 1, 1)
                            .addComponent(panel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(button2, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addComponent(label1, GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label2)
                        .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(32, 32, 32)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                        .addComponent(button1)
                        .addComponent(button2)
                        .addComponent(panel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(81, Short.MAX_VALUE))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JLabel label1;
    private JLabel label2;
    private JTextField textField1;
    private JButton button1;
    private JButton button2;
    private JPanel panel1;
    private back action1;
    private check action2;
    // JFormDesigner - End of variables declaration  //GEN-END:variables

    private class back extends AbstractAction {
        private back() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action1.Name_18"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            dispose();
            new RoomInSet().setVisible(true);
        }
    }

    private class check extends AbstractAction {
        private check() {
            // JFormDesigner - Action initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            ResourceBundle bundle = ResourceBundle.getBundle("com.keshe.jsp.form");

            putValue(NAME, bundle.getString("action2.Name_12"));
            // JFormDesigner - End of action initialization  //GEN-END:initComponents
        }

        public void actionPerformed(ActionEvent e) {
            // TODO add your code here
            RoomInContorller ri=new RoomInContorller();
            int flag=ri.updateRoomInNull(textField1.getText());
            switch(flag){
                case -1: {
                    JOptionPane.showMessageDialog(null,"输入用户身份证号才能进行操作哦！");
                    break;
                }
                case 0: {
                    JOptionPane.showMessageDialog(null,"该用户尚未订房");
                    break;
                }
                default: {
                    JOptionPane.showMessageDialog(null,"退房成功！");
                    dispose();
                    new RoomInSet().setVisible(true);
                    break;
                }
            }
        }
    }
}
